home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1992 / 11 / 02 / makecat / c-beispiel / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  1.7 KB  |  73 lines

  1. #include <exec/types.h>
  2. #include <exec/libraries.h>
  3. #include <libraries/locale.h>
  4. #include <utility/tagitem.h>
  5.  
  6. #include <clib/exec_protos.h>
  7. #include <clib/dos_protos.h>
  8.  
  9. #include <pragmas/exec_pragmas.h>
  10. #include <pragmas/dos_pragmas.h>
  11.  
  12. /*
  13.  * Die foglende DEFINE-Anweisung darf in einem Projekt nur
  14.  * einmal erscheinen.
  15.  */
  16. #define LOCALE_TEXT
  17.  
  18. #include "test.h"
  19.  
  20. extern struct Library   *DOSBase;
  21. extern struct Library   *SysBase;
  22.  
  23. struct Library *LocaleBase=NULL;
  24. struct Catalog *mycatalog=NULL;
  25.  
  26. char *CatalogName="test.catalog";
  27.  
  28. /*
  29.  * protos
  30.  */
  31. struct Locale *OpenLocale(STRPTR);
  32. struct Catalog *OpenCatalogA(struct Locale *, STRPTR, APTR);
  33. STRPTR GetLocaleStr( struct Locale *, ULONG );
  34. STRPTR GetCatalogStr(struct Catalog *, LONG, STRPTR );
  35. BOOL   CloseLocale( struct Locale * );
  36. BOOL   CloseCatalog( struct Catalog *);
  37.  
  38. /*
  39.  * Diese Funktion holt den gewünschten String aus dem Katalog und
  40.  * gibt den Pointer auf diesen zurück. Rufen Sie diese Funktion
  41.  * mit dem Pointer auf die LocText-Struktur auf.
  42.  */
  43. char *GetMyLocaleString(struct Catalog *mycat, struct LocText *loctext ) {
  44.   if( mycat ) {
  45.     GetCatalogStr(mycat,loctext->id,NULL);
  46.   } else return loctext->text;
  47. }
  48.  
  49.  
  50. VOID main(ULONG argc, char **argv) {
  51.  
  52.   if( argc ) {
  53.     /*
  54.      * Nur vom CLI zu starten
  55.      */
  56.     LocaleBase=OpenLibrary("locale.library",38);
  57.  
  58.     if( LocaleBase )
  59.       mycatalog=OpenCatalogA(NULL,CatalogName,NULL);
  60.  
  61.     printf("String 1=%s\nString 2=%s\nString 3=%s\n",
  62.             GetMyLocaleString(mycatalog, &FirstText ),
  63.             GetMyLocaleString(mycatalog, &SecondText ),
  64.             GetMyLocaleString(mycatalog, &Bye ));
  65.  
  66.     if( mycatalog )
  67.       CloseCatalog( mycatalog );
  68.  
  69.     if( LocaleBase )
  70.       CloseLibrary(LocaleBase);
  71.   }
  72. }
  73.